package com.zr.d_c.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.d_c.model.Evaluate;
import com.zr.d_c.service.EvaluateService;
import com.zr.d_c.serviceimpl.EvaluateServiceImpl;
/**
 * 增加评论
 * @author Administrator
 *
 */
public class AddEvaluateController extends HttpServlet {

	EvaluateService evaluateservice = new EvaluateServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter pw = resp.getWriter();
		String oid = req.getParameter("oid");
		String evaluate = req.getParameter("evaluate");
		Date date = new Date();	
		SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
		Evaluate ev = new Evaluate();
		ev.setEcreatetime(f.format(date));
		ev.setEisdelete(1);
		ev.setOid(Integer.parseInt(oid));
		ev.setEtext(evaluate);
		if(evaluateservice.addEvaluateByOid(ev, Integer.parseInt(oid))>0){
			pw.write("1");
		}else{
			pw.write("0");
		}
		pw.close();
	}
}
